/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Model;

import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

/**
 *
 * @author KimCuc
 */
public class bean_timve {
    private String MaCB;
    private String MaVe;
    private String NoiDi;
    private String NoiDen;
    private Date NgayDi;    
    private String LoaiVe;
    private float GiaVe;
    private boolean TrangThai;
    
    
    public String getMaVe() {
        return MaVe;
    }

    public void setMaVe(String MaVe) {
        this.MaVe = MaVe;
    }

    public String getMaCB() {
        return MaCB;
    }

    public void setMaCB(String MaCB) {
        this.MaCB = MaCB;
    }

    public String getLoaiVe() {
        return LoaiVe;
    }

    public void setLoaiVe(String LoaiVe) {
        this.LoaiVe = LoaiVe;
    }
    
    public String getNoiDen() {
        return NoiDen;
    }

    public void setNoiDen(String NoiDen) {
        this.NoiDen = NoiDen;
    }

    public String getNoiDi() {
        return NoiDi;
    }

    public void setNoiDi(String NoiDi) {
        this.NoiDi = NoiDi;
    }

    public float getGiaVe() {
        return GiaVe;
    }

    public void setGiaVe(float GiaVe) {
        this.GiaVe = GiaVe;
    }
      public Date getNgayDi() {
        return NgayDi;
    }

    public void setNgayDi(Date NgayDi) {
        this.NgayDi = NgayDi;
    }

    public boolean isTrangThai() {
        return TrangThai;
    }

    public void setTrangThai(boolean TrangThai) {
        this.TrangThai = TrangThai;
    }

    
    public bean_timve(){};
    public bean_timve(String MaVe,String MaCB,String NoiDi,String NoiDen,Date NgayDi,String LoaiVe,Float GiaVe,boolean TrangThai){
    this.MaVe=MaVe;
    this.MaCB=MaCB;
    this.NoiDi=NoiDi;
    this.NgayDi=NgayDi;
    this.NoiDen=NoiDen;
    this.LoaiVe=LoaiVe;
    this.GiaVe=GiaVe;
    this.TrangThai=TrangThai;
    }
    public ResultSet timve(String NoiDi, String NoiDen) {
        Connection con = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        try {
           con = Connect.GetConnect();
            String sql = "SELECT * FROM ve WHERE NoiDi= ? and NoiDen=?";
            stm = con.prepareStatement(sql);
            stm.setString(1, NoiDi);
            stm.setString(2, NoiDen);
            rs = stm.executeQuery();
            return rs;
//            ArrayList list = new ArrayList();
//
//            while (rs.next()) {
//                String mave = rs.getString("MaVe");
//                String macb = rs.getString("MaCB");
//                String noidi = rs.getString("NoiDi");
//                String noiden = rs.getString("NoiDen");
//                Date ngaydi = rs.getDate("NgayBay");
//                String loaive = rs.getString("LoaiVe");   
//                float giave=rs.getFloat("GiaVe");
//                boolean trangthai=rs.getBoolean("TrangThai");              
//                bean_timve tv = new bean_timve(mave, macb, noidi, noiden,ngaydi, loaive,giave,trangthai);
//                list.add(tv);
//            }
//            bean_timve[] result = new bean_timve[list.size()];
//            list.toArray(result);
//            rs.close();
//            stm.close();
//            con.close();
//            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * @return the NgayDi
     */
  
    

  
    
}
